package model.bean;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import util.Constants;
@NamedQueries({ @NamedQuery(name = "findByDescricao", query = "SELECT n FROM Nucleo n "
		+ " WHERE n.descricao = :descricao " 
),@NamedQuery(name = "findByDescricaoPesquisa", query = "SELECT n FROM Nucleo n "
		+ " WHERE n.descricao like :descricao" 
) })
@Entity
@Table(name = Constants.DATABASE_TABLE_NUCELO, schema = Constants.DATABASE_NOME)
public class Nucleo implements Serializable {

	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer idNucleo;

	@Column(name = "descricao", insertable = true, updatable = true)
	private String descricao;

	public Nucleo() {
	}

	public Nucleo(int idNucleo, String descricao) {
		this.idNucleo = idNucleo;
		this.descricao = descricao;
	}

	public Integer getIdNucleo() {
		return idNucleo;
	}

	public void setIdNucleo(Integer idNucleo) {
		this.idNucleo = idNucleo;
	}

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((getIdNucleo() == null) ? 0 : getIdNucleo().hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Nucleo other = (Nucleo) obj;
		if (getIdNucleo() == null) {
			if (other.getIdNucleo() != null)
				return false;
		} else if (!getIdNucleo().equals(other.getIdNucleo()))
			return false;
		return true;
	}

}
